<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>取消请求</title>
</head>
<body>
<button>发送请求</button>
<button>取消请求</button>
<script>
    const btns = document.querySelectorAll("button");
    let x = null;
    btns[0].onclick = function () {
        x = new XMLHttpRequest();
        x.open('GET', 'http://localhost:8080/net-work-time-out')
        x.send();
    }
    btns[1].onclick = function () {
        x.abort();
    }
</script>
</body>
</html>